package dfbz.线程的操作;

public class demo01 {
    public static void main(String[] args) {
       // public static void sleep(long millis) ：让当前线程睡眠指定的毫秒数

        demo1();//睡眠
    }

    private static void demo1() {
        new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    if(i==50){
                        try {
                            Thread.sleep(2000);//睡眠两秒
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    System.out.println("线程1:"+i);
                }
            }
        }.run();
        new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("线程2:"+i);
                }
            }
        }.run();
    }
}
